package no.progark.Copter;

import sheep.game.Sprite;
import sheep.graphics.Image;


public class Copter extends Sprite {
	public float velocity = 150.0f;
	public float currentVel = 2.0f;
	public Direction direction;
	public float dx, dy;
	
	public Copter(Image image, boolean resetPos) {
		super(image);
		if(resetPos){
			setPosition(100.0f, 900.0f);
			direction = Direction.UP;
		}	
	}

	@Override
	public void update(float dt) {
		super.update(dt);
		float x = getX();
		float y = getY();

		if(x > 1000 && direction == Direction.RIGHT) {
			velocity = -velocity;
		}
		if(x < 0 && direction == Direction.LEFT) {
			velocity = -velocity;
		}
		if(y > 1000 && direction == Direction.UP) {
			velocity = -velocity;
		}
		if(y < 0 && direction == Direction.DOWN) {
			velocity = -velocity;
		}
		
		switch(direction) {
		case LEFT:
			dx = dt * velocity;
			setPosition(x - dx, y);
			break;
				
		case RIGHT:
			dx = dt * velocity;
			setPosition(x + dx, y);
			break;
		
		case UP:
			dy = dt * velocity;
			setPosition(x, y + dy);
		
		case DOWN:
			dy = dt * velocity;
			setPosition(x, y - dy);
		}
	}
}